<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        var arr1 = [1, 2, 3]
        console.log(arr1);

        arr1.splice(0, 1, '我是splice添加进来的哦！', '我也是splice添加进来的哦！')
        // 从索引位置0开始删除，删除1位，随后添加属性
        // 输出:["我是splice添加进来的哦！", "我也是splice添加进来的哦！", 2, 3]
        console.log(arr1);
        console.log('====================================================');

        var arr2 = [1, 2, 3];
        var arrNew = arr2.concat(3, 4, 5)
        console.log(arrNew);

        console.log('====================================================');


        var arr = ['2021', 10, '28'];
        var arrJoin = arr.join('-'); // 输出:2021-10-28
        console.log(arrJoin);

        console.log('====================================================');

        var arr11 = [['张三', '李四'], [18, 23]]
        console.log(arr11[0][0], arr11[1][1]) //张三 23

        console.log('====================================================');
        

        /* Array提供了一种顺序存储一组元素的功能，并可以按索引来读写。
        练习：在新生欢迎会上，你已经拿到了新同学的名单，请排序后显示：欢迎XXX，XXX，XXX和XXX同学！：

        'use strict';
        var arr = ['小明', '小红', '大军', '阿黄'];
        console.log('???'); */


        var arr = ['小明', '小红', '大军', '阿黄'];
        var str='';
        arr.sort();
        for (var i = 0; i < arr.length; i++) 
        {

             if(i===0){
                 str=str+'欢迎'+arr[i];
             }else if(i<3){
                 str=str+'，'+arr[i];
             }
        }
        str=str+'和'+arr[3]+'同学!'
        console.log(str);
    </script>
</body>

</html>